<template name="sendcar">
	<view class="mypage">
		<view class="bg-white font-40">
			<view class="flex  p-xs margin-bottom-sm mb-sm text-black">
				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('S1001')== -1 ?false:true " @click="approvalList(0)">
					<view class="text-xxl text-bold text-myred font-45">
						{{ approval.approvalNum || 0 }}
					</view>
					<view class="text-blue text-black margin-top">待审批</view>
				</view>

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('S1002')== -1 ?false:true " @click="approvalList(1)">
					<view class="text-xxl text-bold text-myred">
						{{ approval.approvedNum || 0 }}
					</view>
					<view class="text-cyan text-black margin-top">已审批</view>
				</view>

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('S1003')== -1 ?false:true " @click="approvalList(2)">
					<view class="text-xxl text-bold text-myred">
						{{ approval.rejectNum || 0 }}
					</view>
					<view class="text-cyan text-black margin-top">已驳回</view>
				</view>

			</view>
		</view>

		<view class="cu-bar bg-white solid-bottom ">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue "></text>库移位
			</view>
		</view>
		<view class="bg-white nav text-center ">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1001')== -1 ?false:true " @click="openDetail('库内移位,M1015')">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue">库内移位</view>
				</view>

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1002')== -1 ?false:true "
					@click="gotoPath( 'new_shift/new_shift?title=库间移位申请&type=ware')">
					<view class="text-sl">
						<text class="cuIcon-form text-cyan "></text>
					</view>
					<view class="text-cyan">库间移位申请</view>
				</view>

				<view class="flex-sub padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1003')== -1 ?false:true "
					@click="gotoPath( 'new_shift/over_list?title=库间移位申单&type=ware')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">库间移出</view>
				</view>

				<view class="flex-sub padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1004')== -1 ?false:true "
					@click="gotoPath( 'new_shift/order_out_list?title=库间移出单&type=ware')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">库间移入</view>
				</view>

			</view>
		</view>

		<view class="cu-bar bg-white solid-bottom ">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>组织移位
			</view>
		</view>
		<view class="bg-white nav text-center">
			<view class="flex font-35  p-xs margin-bottom-sm mb-sm">
				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1005')== -1 ?false:true "
					@click="gotoPath( 'new_shift/new_shift?title=组织移位申请&type=org')">
					<view class="text-sl">
						<text class="cuIcon-form text-red "></text>
					</view>
					<view class="text-red">组织移位申请</view>
				</view>

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1006')== -1 ?false:true "
					@click="gotoPath( 'new_shift/over_list?title=组织移位申请单&type=org')">
					<view class="text-sl">
						<text class="cuIcon-form text-yellow "></text>
					</view>
					<view class="text-yellow">组织移出</view>
				</view>

				<view class="flex-sub padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1007')== -1 ?false:true "
					@click="gotoPath( 'new_shift/order_out_list?title=组织移出单&type=org')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">组织移入</view>
				</view>

			</view>
		</view>

		<view class="cu-bar bg-white solid-bottom">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>公司移位
			</view>
		</view>
		<view class="bg-white nav text-center">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">
				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1008')== -1 ?false:true "
					@click="gotoPath( 'new_shift/new_shift?title=公司移位申请&type=company')">
					<view class="text-sl">
						<text class="cuIcon-form text-red "></text>
					</view>
					<view class="text-red">公司移位申请</view>
				</view>

				<view class="flex-sub  padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1009')== -1 ?false:true "
					@click="gotoPath( 'new_shift/over_list?title=公司移位申请单&type=company')">
					<view class="text-sl">
						<text class="cuIcon-form text-yellow "></text>
					</view>
					<view class="text-yellow">公司移出</view>
				</view>

				<view class="flex-sub padding-sm margin-xs radius flex-item-center"
					v-if="userInfo.authModel.indexOf('Y1010')== -1 ?false:true "
					@click="gotoPath( 'new_shift/order_out_list?title=公司移出单&type=company')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">公司移入</view>
				</view>

			</view>
		</view>

		<!-- 物资跟踪 -->

		<view class="cu-bar bg-white solid-bottom">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>物资跟踪
			</view>
		</view>

		<view class="bg-white nav text-center ">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">
				<view class=" padding-sm  radius flex-item-center"
					@click="gotoPath( 'Imputation/marter-list?title=待归集&type=1')">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue ">待归集</view>
				</view>

				<view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G102') "
					@click="gotoPath( 'Imputation/has-repay?title=已归集&type=1')">
					<view class="text-sl">
						<text class="cuIcon-form text-red "></text>
					</view>
					<view class="text-red">已归集</view>
				</view>
				
				<view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G103') "
					@click=" isShowWZGL = !isShowWZGL">
					<view class="text-sl">
						<text class="cuIcon-form text-yellow "></text>
					</view>
					<view class="text-yellow">物资管理</view>
				</view>
				<view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G104') "
					@click="isShowJKGL = !isShowJKGL ">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">监控管理</view>
				</view>
				
			</view>
		</view>

		<view class="cu-bar bg-white solid-bottom" v-if="isShowWZGL">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>
				<text class="cuIcon-titles text-blue" style="margin-left: 0;"></text>
				物资管理
			</view>
		</view>
		<view class="bg-white nav text-center " v-if="isShowWZGL">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">
				<view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G106') "
					@click="gotoPath( 'Imputation/count-list?title=统计组织&type=1')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">归集统计</view>
				</view>
				<view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G103') "
					@click="gotoPath( 'patrol/plan-list?title=定检计划&type=1')">
					<view class="text-sl">
						<text class="cuIcon-form text-yellow "></text>
					</view>
					<view class="text-yellow">物资定检</view>
				</view>
				
				<view class=" padding-sm  radius flex-item-center"
					@click="gotoPath('/pages/public/list?type=menu1002')">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue">临检计划</view>
				</view>
				
				<!-- <view class="padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G104') "
					@click="gotoPath( 'patrol/submit?title=物资临检&type=0')">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">物资临检</view>
				</view> -->
				
				
				
				<view class=" padding-sm  radius flex-item-center"
					@click="gotoPath( 'upkeep/mater-list?title=待维修列表&type=1')">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue">物资维修</view>
				</view>
				<view class=" padding-sm  radius flex-item-center"
					@click="gotoPath( 'onsite/over-list?title=物资报废&type=4')">
					<view class="text-sl">
						<text class="cuIcon-form text-red "></text>
					</view>
					<view class="text-red">物资报废</view>
				</view>
				
				<view class=" padding-sm  radius flex-item-center"
					@click="gotoPath('/pages/public/list?type=menu1001')">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue">现场物资登记</view>
				</view>
				
				
				
			</view>
		</view>
		
		<view class="cu-bar bg-white solid-bottom" v-if="isShowJKGL">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>
				<text class="cuIcon-titles text-blue" style="margin-left: 0;"></text>
				监控管理
			</view>
		</view>
		<view class="bg-white nav text-center " v-if="isShowJKGL">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">
				<view class=" padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G105') " @click="gotoNativePage(1)">
					<view class="text-sl">
						<text class="cuIcon-form text-green "></text>
					</view>
					<view class="text-green">监控云台</view>
				</view>
				
				<view class=" padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G105') " @click="gotoNativePage(2)">
					<view class="text-sl">
						<text class="cuIcon-form text-blue "></text>
					</view>
					<view class="text-blue">监控轨迹</view>
				</view>
				<view class=" padding-sm  radius flex-item-center" v-if="userInfo.authModel.includes('G105') " @click="gotoNativePage(3)">
					<view class="text-sl">
						<text class="cuIcon-form text-red "></text>
					</view>
					<view class="text-red">数量识别</view>
				</view>
			</view>
		</view>
		
		


		<view class="cu-bar bg-white solid-bottom">
			<view class="action font-35">
				<text class="cuIcon-titles text-blue"></text>外销水泥
			</view>
		</view>


		<view class="bg-white nav text-center ">
			<view class="flex-wrap font-35  p-xs margin-bottom-sm mb-sm">
				<view class="padding-sm  radius flex-item-center" :class="colors[indexM]" @click="handelMenu(itemM)" v-for="(itemM,indexM) in wxsnArr"
					:key="itemM.name">
					<view class="text-sl">
						<text class="cuIcon-form  "></text>
					</view>
					<view class=" ">{{ itemM.name }}</view>
				</view>
			</view>
		</view>

	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js'
	var testModule = uni.requireNativePlugin("TestModule")
	let _self;
	export default {
		computed: mapState(['userInfo', 'approval']),
		data() {
			return {
				isShowWZGL: false,
				isShowJKGL: false, 
				approvalNum: 0,
				approvedNum: 0,
				rejectNum: 0,
				planList: [1, 2, 3, 5, 8, 9],
				colors:['text-blue','text-green','text-red', 'text-orange','text-yellow'],
				wxsnArr: [{
						name: '交货单入库',
						path: '/pages/tab01/ton-pack/saleorder',
						icon: '/static/menu/ico_cc_jhdrk.png',
						sqlTbName: 'DB_INSTOCK',
						auth: 'R1001'
					},
					{
						name: '查询入库单',
						path: '/pages/tab01/ton-pack/over-list',
						icon: '/static/menu/ico_cc_rkdcx.png',
						sqlTbName: '0',
						auth: 'R1001'
					},
					{
						name: '入库单出库',
						path: '/pages/tab01/ton-pack/over-list',
						icon: '/static/menu/ico_cc_ckdcx.png',
						sqlTbName: '2',
						auth: 'R1001'
					},
					{
						name: '出库单',
						path: '/pages/tab01/ton-pack/over-list',
						icon: '/static/menu/ico_cc_ckdcx.png',
						sqlTbName: '1',
						auth: 'R1001'
					},
					{
						name: '质保书',
						path: '/pages/tab01/ton-pack/weight',
						icon: '/static/menu/ico_cc_smcx.png',
						sqlTbName: '1',
						auth: 'R1001'
					}
				]

			};
		},
		onLoad() {
			_self = this
			// this.getNum();
		},
		onShow() {
			this.getNum();
		},
		methods: {
			...mapMutations(['setApprovalNum']),
			openDetail(e) {
				let openUrl;
				var list = e.split(",");
				var i = list[1];
				console.log(i);
				switch (i) {
					case 'M1015':
						openUrl = '/pages/tab04/cune_shift/cune_shift?title=库内移位新增&type=';
						break;
					case 'M1016':
						openUrl = '/pages/tab04/new/submit_cf?title=库内移位新增&type=';
						break;
					case 'M1017':
						openUrl = '/pages/tab04/ApplicationList?type=0';
						break;
					case 'M1018':
						openUrl = '/pages/tab04/ApplicationList?type=M1018';
						break;

					case 'M1019':
						openUrl = '/pages/tab04/list3';
						break;
					case 'M1020':
						openUrl = '/pages/tab04/list4';
						break;
					case 'M1021':
						openUrl = '/pages/tab04/list4';
						break;
					case 'M1022':
						openUrl = '/pages/tab04/list5';
						break;
					case 'M1023':
						openUrl = '/pages/tab04/list6';
						break;
					case 'M1024':
						openUrl = '/pages/tab04/list6';
						break;
					default:
						break;
				}
				console.log(openUrl);
				uni.navigateTo({
					url: openUrl + i
				})
			},
			approvalList(e) {
				let a = {
					0: '待审批单',
					1: '已审批单',
					2: '已驳回单'
				};
				// let t = e == 0?'待审批单':'已审批单';
				uni.navigateTo({
					url: '/pages/tab04/approval?n=' + a[e] + '&type=' + e
				})
			},

			gotoNativePage(type) {
				let sxtIP = type == 3 ? '192.168.72.113' : '192.168.72.112'
				testModule.gotoNativePage(
					getApp().globalData.Token,
					'http://61.133.208.158:82',
					type,
					sxtIP,
					'admin',
					'nxjc@2015',
					8000,
					34,
					'192.168.72.111',
					'admin',
					'nxjc@2015',
					8000,
					34,
					'',
					'',
					'WH000000000000000368',
					'',
					''
				);
			},

			handelMenu(menu) {
				console.log(menu);
				if (menu.sqlTbName == 'ScanIn' || menu.sqlTbName == 'ScanOut') {
					return _self.openScan();
				}
				let path = menu.path + '?pageTitle=' + menu.name + '&sqlTbName=' + menu.sqlTbName + '&auth=' + menu.auth;
				// console.log(path);
				uni.navigateTo({
					url: path
				})
			},

			// 获取待审批数量
			getNum() {
				let query = {
					"page": 1,
					"rows": "10",
					"sidx": "",
					"sord": "",
					"queryJson": "{\"ISFINISH\":\"0\",\"StartTime\":\"\",\"EndTime\":\"\"}",
					"userId": this.userInfo.UserId,
					"account": this.userInfo.Account
				}
				let _self = this;
				let URL = this.userInfo.BaseURL + api.apiPublic.approvalList;
				this.axios({
					url: URL,
					data: query
				}).then(res => {
					let {
						IsSuccess,
						Result
					} = res;
					// console.log(Result);
					if (!IsSuccess) return null;
					let approvalNum = Result.approvalnum || 0;
					let approvedNum = Result.approvednum1 || 0;
					let rejectNum = Result.approvednum2 || 0;
					_self.setApprovalNum({
						approvalNum,
						approvedNum,
						rejectNum
					})
					uni.setTabBarBadge({
						index: 2,
						text: approvalNum.toString()
					})
				})
			},

			// 页面跳转
			gotoPath(path) {
				uni.navigateTo({
					url: path
				})
			}


		}
	}
</script>

<style scoped lang="scss">
	.height50 {
		height: 50px;
	}

	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;

	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}

	.flex-wrap {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start !important;

		.flex-item-center {
			width: 25% !important;
			white-space: break-spaces;
		}
	}
</style>